home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / Clueless.swf / scripts / Forms / AchievementsForm.as next >
Encoding:
Text File  |  2011-10-17  |  18.9 KB  |  436 lines

  1. package Forms
  2. {
  3.    import Common.SoundManager;
  4.    import caurina.transitions.Tweener;
  5.    import flash.display.DisplayObject;
  6.    import flash.display.MovieClip;
  7.    import flash.display.SimpleButton;
  8.    import flash.events.MouseEvent;
  9.    import flash.geom.ColorTransform;
  10.    import flash.text.TextField;
  11.    
  12.    [Embed(source="/_assets/assets.swf", symbol="Forms.AchievementsForm")]
  13.    public class AchievementsForm extends CluelessBaseForm
  14.    {
  15.        
  16.       
  17.       public var _mcAward0:Medal;
  18.       
  19.       public var _mcAward3:Medal;
  20.       
  21.       public var _mcAward4:Medal;
  22.       
  23.       internal var _iCurrentMedal:int = 0;
  24.       
  25.       public var _mcAward1:Medal;
  26.       
  27.       public var _mcAward2:Medal;
  28.       
  29.       internal var _aAchievements:Array;
  30.       
  31.       internal var _iTotalMedals:int;
  32.       
  33.       public var _tfAwardName:TextField;
  34.       
  35.       internal const MOVE_TIME:Number = 1;
  36.       
  37.       public var _tfAwardDescription:TextField;
  38.       
  39.       public var _bPrev:ArrowTriangle;
  40.       
  41.       public var _tfAwardStatus:TextField;
  42.       
  43.       public var _bNext:ArrowTriangle;
  44.       
  45.       internal var _aSlots:Array;
  46.       
  47.       public var _bExit:SimpleButton;
  48.       
  49.       internal const CENTER_SLOT:int = 2;
  50.       
  51.       public var _bMenu:ButtonRound;
  52.       
  53.       protected var _dragcontroller:DragController;
  54.       
  55.       internal const NUM_SLOTS:int = 5;
  56.       
  57.       public function AchievementsForm()
  58.       {
  59.          var _loc1_:int = 0;
  60.          var _loc2_:Medal = null;
  61.          var _loc3_:int = 0;
  62.          var _loc4_:String = null;
  63.          var _loc5_:DisplayObject = null;
  64.          _dragcontroller = new DragController();
  65.          _aSlots = new Array();
  66.          _aAchievements = new Array();
  67.          _iCurrentMedal = 0;
  68.          super();
  69.          _loc1_ = 0;
  70.          while(_loc1_ < NUM_SLOTS)
  71.          {
  72.             _loc4_ = "_mcAward" + _loc1_;
  73.             _loc5_ = getChildByName(_loc4_);
  74.             _aSlots.push(_loc5_);
  75.             _loc5_.visible = false;
  76.             _loc1_++;
  77.          }
  78.          _bPrev.addEventListener(MouseEvent.CLICK,onPrev,false,0,true);
  79.          _bNext.addEventListener(MouseEvent.CLICK,onNext,false,0,true);
  80.          _loc2_ = new Medal();
  81.          _iTotalMedals = _loc2_.totalFrames;
  82.          _loc3_ = getChildIndex(_mcAward0);
  83.          _loc1_ = 0;
  84.          while(_loc1_ <= _iTotalMedals)
  85.          {
  86.             _loc2_ = new Medal();
  87.             _loc2_.x = 0;
  88.             _loc2_.y = 0;
  89.             _loc2_.gotoAndStop(_loc1_);
  90.             addChildAt(_loc2_,_loc3_);
  91.             _aAchievements.push(_loc2_);
  92.             _loc1_++;
  93.          }
  94.          setBackButton(_bExit);
  95.          installMouseOverSound(_bExit);
  96.          _iCurrentMedal = 0;
  97.          showMedals(_iCurrentMedal,0);
  98.       }
  99.       
  100.       internal function cleanupMedals() : void
  101.       {
  102.          var _loc1_:int = 0;
  103.          var _loc2_:Medal = null;
  104.          _loc1_ = 0;
  105.          while(_loc1_ <= _iTotalMedals)
  106.          {
  107.             _loc2_ = _aAchievements[_loc1_];
  108.             if(Profile.CurrentProfile.isAchievementUnlocked(_loc2_.currentLabel))
  109.             {
  110.                _loc2_.filters = null;
  111.                _loc2_.transform.colorTransform = new ColorTransform();
  112.             }
  113.             else
  114.             {
  115.                _loc2_.filters = _mcAward1.filters;
  116.                _loc2_.transform.colorTransform = _mcAward1.transform.colorTransform;
  117.             }
  118.             Tweener.removeTweens(_loc2_);
  119.             _loc2_.visible = false;
  120.             _loc1_++;
  121.          }
  122.       }
  123.       
  124.       override public function onFocus() : void
  125.       {
  126.          super.onFocus();
  127.          if((Profile.CurrentProfile.TutorialMask & Profile.kTutorial_Honors) == 0)
  128.          {
  129.             setTutorial(new MCTutorialHonors());
  130.             Profile.CurrentProfile.TutorialMask |= Profile.kTutorial_Honors;
  131.             Storage.getInstance().saveProfiles();
  132.          }
  133.       }
  134.       
  135.       internal function getSlot(param1:int) : MovieClip
  136.       {
  137.          return _aSlots[param1] as MovieClip;
  138.       }
  139.       
  140.       internal function onPrev(param1:MouseEvent) : void
  141.       {
  142.          --_iCurrentMedal;
  143.          _iCurrentMedal = normalizeIndex(_iCurrentMedal);
  144.          showMedals(_iCurrentMedal,1);
  145.          SoundManager.getInstance().playSound("ScrollAwardsSound");
  146.       }
  147.       
  148.       internal function onNext(param1:MouseEvent) : void
  149.       {
  150.          ++_iCurrentMedal;
  151.          _iCurrentMedal = normalizeIndex(_iCurrentMedal);
  152.          showMedals(_iCurrentMedal,-1);
  153.          SoundManager.getInstance().playSound("ScrollAwardsSound");
  154.       }
  155.       
  156.       internal function updateText(param1:String) : void
  157.       {
  158.          var _loc2_:String = null;
  159.          var _loc3_:* = null;
  160.          var _loc4_:* = null;
  161.          _loc2_ = "";
  162.          _loc3_ = "";
  163.          _loc4_ = "";
  164.          switch(param1)
  165.          {
  166.             case "asian flair":
  167.                _loc2_ = "Asian Flair Award";
  168.                _loc3_ = "Get " + AchievementsList.OCCASION_MATCH_NUM + " good matches in a Asian Flair level.";
  169.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Asian Flair","TotalOccasionGoodMatches") + " of " + AchievementsList.OCCASION_MATCH_NUM;
  170.                break;
  171.             case "beach":
  172.                _loc2_ = "Beach Wear Award";
  173.                _loc3_ = "Get " + AchievementsList.OCCASION_MATCH_NUM + " good matches in a Beach Wear level.";
  174.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Beach","TotalOccasionGoodMatches") + " of " + AchievementsList.OCCASION_MATCH_NUM;
  175.                break;
  176.             case "carpet":
  177.                _loc2_ = "Red Carpet Ready Award";
  178.                _loc3_ = "Get " + AchievementsList.OCCASION_MATCH_NUM + " good matches in a Red Carpet level.";
  179.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Carpet","TotalOccasionGoodMatches") + " of " + AchievementsList.OCCASION_MATCH_NUM;
  180.                break;
  181.             case "crown":
  182.                _loc2_ = "Crown Award";
  183.                _loc3_ = "Finish the game while using power-ups.";
  184.                break;
  185.             case "corporate":
  186.                _loc2_ = "Corporate Style Award";
  187.                _loc3_ = "Get " + AchievementsList.OCCASION_MATCH_NUM + " good matches in Corporate Style level.";
  188.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Corporate","TotalOccasionGoodMatches") + " of " + AchievementsList.PARTNER_MATCH_NUM;
  189.                break;
  190.             case "club wear":
  191.                _loc2_ = "Club Wear Award";
  192.                _loc3_ = "Get " + AchievementsList.OCCASION_MATCH_NUM + " good matches in a Club Wear level.";
  193.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Club Wear","TotalOccasionGoodMatches") + " of " + AchievementsList.OCCASION_MATCH_NUM;
  194.                break;
  195.             case "david":
  196.                _loc2_ = "David Award";
  197.                _loc3_ = "Wow David " + AchievementsList.PARTNER_MATCH_NUM + " times.";
  198.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("David","TotalPerfectMatches") + " of " + AchievementsList.PARTNER_MATCH_NUM;
  199.                break;
  200.             case "elton":
  201.                _loc2_ = "Elton Award";
  202.                _loc3_ = "Wow Elton " + AchievementsList.PARTNER_MATCH_NUM + " times.";
  203.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Elton","TotalPerfectMatches") + " of " + AchievementsList.PARTNER_MATCH_NUM;
  204.                break;
  205.             case "power":
  206.                _loc2_ = "Girl Power Award";
  207.                _loc3_ = "Finish the game without using any power-ups.";
  208.                break;
  209.             case "formal":
  210.                _loc2_ = "Formal Award";
  211.                _loc3_ = "Get " + AchievementsList.OCCASION_MATCH_NUM + " good matches in a Formal Wear level.";
  212.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Formal","TotalOccasionGoodMatches") + " of " + AchievementsList.OCCASION_MATCH_NUM;
  213.                break;
  214.             case "golden":
  215.                _loc2_ = "Golden Cher Award";
  216.                _loc3_ = "Match all the girls with their respective partners.";
  217.                break;
  218.             case "grunge":
  219.                _loc2_ = "L.A. Grunge Award";
  220.                _loc3_ = "Get " + AchievementsList.OCCASION_MATCH_NUM + " good matches in a L.A. Grunge level.";
  221.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Grunge","TotalOccasionGoodMatches") + " of " + AchievementsList.OCCASION_MATCH_NUM;
  222.                break;
  223.             case "gym":
  224.                _loc2_ = "Gym Award";
  225.                _loc3_ = "Get " + AchievementsList.OCCASION_MATCH_NUM + " good matches in a gym level.";
  226.                break;
  227.             case "halloween":
  228.                _loc2_ = "Halloween Award";
  229.                _loc3_ = "Get " + AchievementsList.OCCASION_MATCH_NUM + " good matches in a halloween level.";
  230.                break;
  231.             case "hip hop":
  232.                _loc2_ = "90`s Hip Hop Award";
  233.                _loc3_ = "Get " + AchievementsList.OCCASION_MATCH_NUM + " good matches in a 90\'s Hip Hop level.";
  234.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Hip Hop","TotalOccasionGoodMatches") + " of " + AchievementsList.OCCASION_MATCH_NUM;
  235.                break;
  236.             case "hollywood":
  237.                _loc2_ = "Vintage Hollywood";
  238.                _loc3_ = "Get " + AchievementsList.OCCASION_MATCH_NUM + " good matches in a Vintage Hollywood level.";
  239.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Hollywood","TotalOccasionGoodMatches") + " of " + AchievementsList.OCCASION_MATCH_NUM;
  240.                break;
  241.             case "josh":
  242.                _loc2_ = "Josh Award";
  243.                _loc3_ = "Wow Josh " + AchievementsList.PARTNER_MATCH_NUM + " times.";
  244.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Josh","TotalPerfectMatches") + " of " + AchievementsList.PARTNER_MATCH_NUM;
  245.                break;
  246.             case "lolita":
  247.                _loc2_ = "Gothic Lolita Award";
  248.                _loc3_ = "Get " + AchievementsList.OCCASION_MATCH_NUM + " good matches in a Gothic Lolita level.";
  249.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Lolita","TotalOccasionGoodMatches") + " of " + AchievementsList.OCCASION_MATCH_NUM;
  250.                break;
  251.             case "luke":
  252.                _loc2_ = "Luke Award";
  253.                _loc3_ = "Wow Luke " + AchievementsList.PARTNER_MATCH_NUM + " times.";
  254.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Luke","TotalPerfectMatches") + " of " + AchievementsList.PARTNER_MATCH_NUM;
  255.                break;
  256.             case "military":
  257.                _loc2_ = "Military Chic Award";
  258.                _loc3_ = "Get " + AchievementsList.OCCASION_MATCH_NUM + " good matches in a Military Chic level.";
  259.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Military","TotalOccasionGoodMatches") + " of " + AchievementsList.OCCASION_MATCH_NUM;
  260.                break;
  261.             case "murray":
  262.                _loc2_ = "Murray Award";
  263.                _loc3_ = "Wow Murray " + AchievementsList.PARTNER_MATCH_NUM + " times.";
  264.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Murray","TotalPerfectMatches") + " of " + AchievementsList.PARTNER_MATCH_NUM;
  265.                break;
  266.             case "nature":
  267.                _loc2_ = "Nature Girl Award";
  268.                _loc3_ = "Get " + AchievementsList.OCCASION_MATCH_NUM + " good matches in a Nature Girl level.";
  269.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Nature","TotalOccasionGoodMatches") + " of " + AchievementsList.OCCASION_MATCH_NUM;
  270.                break;
  271.             case "preppy":
  272.                _loc2_ = "Beverly Hills Preppy";
  273.                _loc3_ = "Get " + AchievementsList.OCCASION_MATCH_NUM + " good matches in a Beverly Hills Preppy level.";
  274.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Preppy","TotalOccasionGoodMatches") + " of " + AchievementsList.OCCASION_MATCH_NUM;
  275.                break;
  276.             case "prom":
  277.                _loc2_ = "Prom Perfect Award";
  278.                _loc3_ = "Get " + AchievementsList.OCCASION_MATCH_NUM + " good matches in a Prom Perfect level.";
  279.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Prom","TotalOccasionGoodMatches") + " of " + AchievementsList.OCCASION_MATCH_NUM;
  280.                break;
  281.             case "rodeo":
  282.                _loc2_ = "Rodeo Drive Rodeo";
  283.                _loc3_ = "Get " + AchievementsList.OCCASION_MATCH_NUM + " good matches for Rodeo Drive Rodeo level.";
  284.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Rodeo","TotalOccasionGoodMatches") + " of " + AchievementsList.OCCASION_MATCH_NUM;
  285.                break;
  286.             case "sean":
  287.                _loc2_ = "Sean Award";
  288.                _loc3_ = "Wow Sean " + AchievementsList.PARTNER_MATCH_NUM + " times.";
  289.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Sean","TotalPerfectMatches") + " of " + AchievementsList.PARTNER_MATCH_NUM;
  290.                break;
  291.             case "slumber":
  292.                _loc2_ = "Slumber Award";
  293.                _loc3_ = "Get " + AchievementsList.OCCASION_MATCH_NUM + " good matches in a slumber party level.";
  294.                break;
  295.             case "sporty":
  296.                _loc2_ = "Sporty Award";
  297.                _loc3_ = "Get " + AchievementsList.OCCASION_MATCH_NUM + " good matches in a Sporty level.";
  298.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Sporty","TotalOccasionGoodMatches") + " of " + AchievementsList.OCCASION_MATCH_NUM;
  299.                break;
  300.             case "travis":
  301.                _loc2_ = "Travis Award";
  302.                _loc3_ = "Wow Travis " + AchievementsList.PARTNER_MATCH_NUM + " times.";
  303.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Travis","TotalPerfectMatches") + " of " + AchievementsList.PARTNER_MATCH_NUM;
  304.                break;
  305.             case "tristan":
  306.                _loc2_ = "Tristan Award";
  307.                _loc3_ = "Wow Tristan " + AchievementsList.PARTNER_MATCH_NUM + " times.";
  308.                _loc4_ = Profile.CurrentProfile.Achievements.getPairCounter("Tristan","TotalPerfectMatches") + " of " + AchievementsList.PARTNER_MATCH_NUM;
  309.                break;
  310.             case "wedding":
  311.                _loc2_ = "Wedding Award";
  312.                _loc3_ = "Get " + AchievementsList.OCCASION_MATCH_NUM + " good matches in a wedding level.";
  313.                break;
  314.             case "head turner":
  315.                _loc2_ = "Head Turner Award";
  316.                _loc3_ = "Impress any boyfriend.";
  317.                break;
  318.             case "total betty":
  319.                _loc2_ = "Total Betty Award";
  320.                _loc3_ = "Impress any boyfriend 20 times.";
  321.                _loc4_ = Profile.CurrentProfile.Impress + " of 20";
  322.                break;
  323.             case "major hottie":
  324.                _loc2_ = "Major Hottie Award";
  325.                _loc3_ = "Impress any boyfriend 50 times.";
  326.                _loc4_ = Profile.CurrentProfile.Impress + " of 50";
  327.                break;
  328.             case "fashionista":
  329.                _loc2_ = "Fashionista Award";
  330.                _loc3_ = "Score a \"C\" (C+, C or C-) average on 3 levels.";
  331.                _loc4_ = Profile.CurrentProfile.Average_C + " of 3";
  332.                break;
  333.             case "trendsetter":
  334.                _loc2_ = "Trendsetter Award";
  335.                _loc3_ = "Score a \"B\" (B+, B or B-) average on 3 levels.";
  336.                _loc4_ = Profile.CurrentProfile.Average_B + " of 3";
  337.                break;
  338.             case "fashion guru":
  339.                _loc2_ = "Fashion Guru Award";
  340.                _loc3_ = "Score an \"A\" (A+, A or A-) average on 3 levels.";
  341.                _loc4_ = Profile.CurrentProfile.Average_A + " of 3";
  342.                break;
  343.             case "fashion queen":
  344.                _loc2_ = "Fashion Queen Award";
  345.                _loc3_ = "Score 15 \"A\" average levels.";
  346.                _loc4_ = Profile.CurrentProfile.Average_A + " of 15";
  347.                break;
  348.             case "fashion goddess":
  349.                _loc2_ = "Fashion Goddess Award";
  350.                _loc3_ = "Score 25 \"A\" average levels.";
  351.                _loc4_ = Profile.CurrentProfile.Average_A + " of 25";
  352.                break;
  353.             case "cutting edge":
  354.                _loc2_ = "Cutting Edge Award";
  355.                _loc3_ = "Score 5000 points on an outfit.";
  356.          }
  357.          _tfAwardName.text = _loc2_;
  358.          _tfAwardDescription.text = _loc3_;
  359.          if(Profile.CurrentProfile.isAchievementUnlocked(param1))
  360.          {
  361.             _tfAwardStatus.text = "ACHIEVED";
  362.          }
  363.          else if(_loc4_ == "")
  364.          {
  365.             _tfAwardStatus.text = "NOT YET ACHIEVED";
  366.          }
  367.          else
  368.          {
  369.             _tfAwardStatus.text = _loc4_;
  370.          }
  371.       }
  372.       
  373.       internal function showMedals(param1:int, param2:int) : void
  374.       {
  375.          var _loc3_:int = 0;
  376.          var _loc4_:int = 0;
  377.          var _loc5_:MovieClip = null;
  378.          var _loc6_:int = 0;
  379.          var _loc7_:Number = NaN;
  380.          cleanupMedals();
  381.          _loc3_ = 0;
  382.          while(_loc3_ < NUM_SLOTS)
  383.          {
  384.             _loc4_ = (param1 - CENTER_SLOT + _loc3_ + _iTotalMedals) % _iTotalMedals;
  385.             _loc4_ = normalizeIndex(_loc4_ - 1) + 1;
  386.             (_loc5_ = _aAchievements[_loc4_]).visible = true;
  387.             if((_loc6_ = _loc3_ - param2) >= 0 && _loc6_ < NUM_SLOTS)
  388.             {
  389.                _loc5_.x = getSlot(_loc6_).x;
  390.                _loc5_.y = getSlot(_loc6_).y;
  391.                _loc5_.width = getSlot(_loc6_).width;
  392.                _loc5_.height = getSlot(_loc6_).height;
  393.                _loc7_ = 0.5;
  394.                if(_loc3_ == CENTER_SLOT)
  395.                {
  396.                   _loc7_ = 1;
  397.                }
  398.                Tweener.addTween(_loc5_,{
  399.                   "x":getSlot(_loc3_).x,
  400.                   "y":getSlot(_loc3_).y,
  401.                   "width":getSlot(_loc3_).width,
  402.                   "height":getSlot(_loc3_).height,
  403.                   "alpha":_loc7_,
  404.                   "time":MOVE_TIME
  405.                });
  406.             }
  407.             else
  408.             {
  409.                _loc5_.x = getSlot(_loc3_).x;
  410.                _loc5_.y = getSlot(_loc3_).y;
  411.                _loc5_.width = getSlot(_loc3_).width;
  412.                _loc5_.height = getSlot(_loc3_).height;
  413.             }
  414.             if(_loc3_ == CENTER_SLOT)
  415.             {
  416.                updateText(_loc5_.currentLabel);
  417.             }
  418.             _loc3_++;
  419.          }
  420.       }
  421.       
  422.       internal function normalizeIndex(param1:int) : int
  423.       {
  424.          while(param1 < 0)
  425.          {
  426.             param1 += _iTotalMedals;
  427.          }
  428.          while(param1 >= _iTotalMedals)
  429.          {
  430.             param1 -= _iTotalMedals;
  431.          }
  432.          return param1;
  433.       }
  434.    }
  435. }
  436.